<template>
  <div @click="btn()">
    <van-nav-bar
    :fixed=true
    left-arrow
     @click-left="onClickLeft"
    >
    </van-nav-bar>
    <div class="address">
      <h2>收货地址</h2>
      <van-address-list
        v-model="chosenAddressId"
        :list="list"
        @add="onAdd"
        @edit="onEdit"
      />
    </div>

  </div>
</template>

<script>
  export default{
    name:'Address',
    data(){
      return{
        chosenAddressId: '1',
         // list: [
         //  {
         //    id: '1',
         //    name:localStorage.getItem('aname'),
         //    tel:localStorage.getItem('tel'),
         //    address:localStorage.getItem('province')+localStorage.getItem('city')+localStorage.getItem('county')+localStorage.getItem('addressDetail'),
         //  },
         //  ]
         list:[]
      }
    },
    methods:{
      onClickLeft(){
        // this.$router.push('/more')
        this.$router.go(-1)
      },
      onAdd() {
        this.$router.push('/newadd')
      },

      onEdit(item, index) {
        this.$router.push('/upadd')
      }
    },
    mounted() {
      if(localStorage.getItem('aname')){
        this.list=[
        {
          id: '1',
          name:localStorage.getItem('aname'),
          tel:localStorage.getItem('tel'),
          address:localStorage.getItem('province')+localStorage.getItem('city')+localStorage.getItem('county')+localStorage.getItem('addressDetail'),
        },
        ]
      }else{
        this.list=[]
      }
    }
  }
</script>

<style scoped="">
  .van-icon-arrow-left{
    color: #bfbfbf;
    font-size: 24px;
  }
  .address{
    padding: 0 20px;
  }
  h2{
    text-align: left;
    font-size: 24px;
    margin-left: 10px;
    line-height: 60px;
  }
  .van-button{
    background: #f3cb0a;
    border: 0;
    font-size: 20px;
    color: #000000;
    font-weight: 600;
  }
</style>
